close all
clc
%% geval 1

n=10000;
a=rand(n,1);
times=zeros(3,3);

% 1.1
tic; for i=1:n; a(i) = sqrt(rand) * a(i); end; times(1,1)=toc;
% 1.2 
tic; b=rand(n,1);for i=1:n; a(i) = sqrt(b(i)) * a(i); end;times(1,2)=toc;

tic; b=sqrt(rand(n,1));for i=1:n; a(i) = b(i) * a(i); end;times(1,3)=toc;
%1.3
tic; b=sqrt(rand(n,1));a=a.*b; times(1,4)=toc;


%% Geval 2

%2.1
tic; for i=1:n; a(i) = sqrt(i) * a(i); end; times(2,1)=toc;

%2.2
tic; b=sqrt(1:n); for i=1:n; a(i) = b(i)*a(i); end; times(2,2)=toc;

%2.3
tic; b=sqrt(1:n); a=a.*b'; times(2,3)=toc;

%% Geval 3

%3.1
tic; for i=1:n; a(i) = sqrt(2) * a(i); end; times(3,1)=toc;

%3.2
tic; sqrt2=sqrt(2); for i=1:n; a(i) =  sqrt2*a(i); end; times(3,2)=toc;

%3.3
tic; a=a*sqrt(2); times(3,3)=toc;

times

